package com.ck.server.controller.register;

import com.ck.common.constant.AjaxResult;
import com.ck.common.core.BaseController;
import com.ck.common.utils.txt.StringUtils;
import com.ck.common.vo.LoginInfoVo;
import com.ck.framework.web.service.SysRegisterService;
import com.ck.system.service.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author changk
 * @date 2024/12/12 15:08
 */
@RestController
public class SysRegisterController extends BaseController {
    @Autowired
    private SysRegisterService registerService;

    @Autowired
    private SysConfigService configService;

    @PostMapping("/register")
    public AjaxResult register(@RequestBody LoginInfoVo user)
    {
        if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
        {
            return error("当前系统没有开启注册功能！");
        }
        String msg = registerService.register(user);
        return StringUtils.isEmpty(msg) ? success() : error(msg);
    }
}
